Imports System.IO
Imports System.Collections
Imports System.Xml

Public Class DisplayGuidance
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub
    Protected WithEvents lblContext As System.Web.UI.WebControls.Label

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If (Not IsPostBack) Then
            Dim index As Integer = 0
            Try
                index = Convert.ToInt32(Request.Item("index"))
            Catch ex As Exception
            End Try
            lblContext.Text = GetGuideNode(index)
        End If
    End Sub

    Protected Function GetGuideNode(ByVal index As Integer) As String
        Dim name As String = ""
        Select Case index
            Case 1
                name = "IDS_Sort"
            Case 2
                name = "Total_Price"
            Case 3
                name = "Priority"
            Case 4
                name = "Note"
            Case 5
                name = "Order_No"
            Case 6
                name = "IDS_FrontPage"
        End Select

        Dim text As String = ReadXML(name)
        If (text.Trim.Length > 0) Then
            Return HttpUtility.HtmlEncode(text)
        Else
            Return ""
        End If
    End Function

    Function ReadXML(ByVal nodeName As String) As String
        Dim value As String = ""
        Dim reader As XmlTextReader
        Try
            Dim fileName As String = Config.GuideFilePath
            reader = New XmlTextReader(fileName)
            While reader.Read()
                If (reader.Name = nodeName AndAlso reader.NodeType = XmlNodeType.Element) Then
                    value = reader.ReadElementString(nodeName)
                    Exit While
                End If
            End While

        Catch ex As Exception
        End Try
        reader.Close()
        reader = Nothing
        Return value
    End Function
End Class
